home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / htment.vbs < prev    next >
Text File  |  2003-08-13  |  5KB  |  156 lines

  1. ' Caption: HTML Entities|
  2. ' Hint: Shows and inserts HTML Entities|
  3. ' Icon: htmlent.ico|
  4. '
  5. '  syn
  6. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  7. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  8. '
  9. '  The contents of this file are subject to the Mozilla Public License
  10. '  Version 1.1 (the "License"); you may not use this file except in compliance
  11. '  with the License. You may obtain a copy of the License at
  12. '  http://www.mozilla.org/MPL/
  13. '
  14. '  Software distributed under the License is distributed on an "AS IS" basis,
  15. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  16. '  the specific language governing rights and limitations under the License.
  17. '
  18. '  The Original Code is htmlent.vbs, released Sun, 26 May 2002 10:55:39 UTC.
  19. '
  20. '  The Initial Developer of the Original Code is Ascher Stefan.
  21. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  22. '  All Rights Reserved.
  23. '
  24. '  Contributor(s): .
  25. '
  26. '  Alternatively, the contents of this file may be used under the terms of the
  27. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  28. '  the provisions of the GPL are applicable instead of those above.
  29. '  If you wish to allow use of your version of this file only under the terms
  30. '  of the GPL and not to allow others to use your version of this file
  31. '  under the MPL, indicate your decision by deleting the provisions above and
  32. '  replace them with the notice and other provisions required by the GPL.
  33. '  If you do not delete the provisions above, a recipient may use your version
  34. '  of this file under either the MPL or the GPL.
  35. '
  36. '  You may retrieve the latest version of this file at the syn home page,
  37. '  located at http://syn.sourceforge.net/
  38. '
  39. ' $Id: htment.vbs,v 1.3.2.5 2003/08/13 00:38:45 neum Exp $
  40.  
  41. option explicit
  42.  
  43. ' Remove the dot to include this files
  44. '#include <consts>
  45. '#include <cmnfunc>
  46.  
  47. const RegKey = "HKCU\Software\Ascher\syn\Macros"
  48.  
  49. dim list
  50.  
  51. sub FormShow(Sender)
  52.   ' Load Settings
  53.   with Sender
  54.     .Width = RegGetSettings(AddBackslash(RegKey) & "he_width", .Width)
  55.     .Height = RegGetSettings(AddBackslash(RegKey) & "he_height", .Height)
  56.     .Top = RegGetSettings(AddBackslash(RegKey) & "he_top", .Top)
  57.     .Left = RegGetSettings(AddBackslash(RegKey) & "he_left", .Left)
  58.   end with
  59. end sub
  60.  
  61. sub FormDestroy(Sender)
  62.   ' Save Settings
  63.   with Sender
  64.     RegSetSettings AddBackslash(RegKey) & "he_width", .Width
  65.     RegSetSettings AddBackslash(RegKey) & "he_height", .Height
  66.     RegSetSettings AddBackslash(RegKey) & "he_top", .Top
  67.     RegSetSettings AddBackslash(RegKey) & "he_left", .Left
  68.   end with
  69. end sub
  70.  
  71. sub LstDlbClick(Sender)
  72.   dim p
  73.   dim sel, v
  74.   if Documents.Count > 0 then
  75.     sel = Sender.Items(Sender.ItemIndex)
  76.     p = InStr(1, sel, vbTab)
  77.     p = InStr(p + 1, sel, vbTab)
  78.     v = Mid(sel, p + 1)
  79.     ActiveDocument.SelText = v
  80.   end if
  81. end sub
  82.  
  83. sub EntityClick(Sender)
  84.   LstDlbClick list
  85. end sub
  86.  
  87. sub CharClick(Sender)
  88.   dim sel, v
  89.   if Documents.Count > 0 then
  90.     sel = list.Items(list.ItemIndex)
  91.     v = Mid(sel, 1, 1)
  92.     ActiveDocument.SelText = v
  93.   end if
  94. end sub
  95.  
  96. sub Main(FileName)
  97.   dim form, pnl
  98.   dim lstfile
  99.   dim i, p, v
  100.   lstfile = AddBackslash(ExtractFilePath(FileName)) & "htmlent.txt"
  101.   if not FileExists(lstfile) then
  102.     MsgBox "File " & lstfile & " not found.", vbCritical
  103.     exit sub
  104.   end if
  105.   form = Create("TForm", Self)
  106.   with form
  107.     .Width = 290
  108.     .Caption = "HTML Entities"
  109.     .BorderIcons = "biSystemMenu"
  110.     .OnShow = "FormShow"
  111.     .OnDestroy = "FormDestroy"
  112.   end with
  113.   pnl = Create("TPanel", form)
  114.   with pnl
  115.     .Parent = form
  116.     .Align = "alTop"
  117.     .Height = 35
  118.     .BevelOuter = "bvNone"
  119.   end with
  120.   with Create("TButton", pnl)
  121.     .Parent = pnl
  122.     .Left = 5
  123.     .Top = 5
  124.     .Caption = "HTML Entity"
  125.     .Hint = "Click to insert the selected HTML Entity"
  126.     .OnClick = "EntityClick"
  127.   end with
  128.   with Create("TButton", pnl)
  129.     .Parent = pnl
  130.     .Left = 85
  131.     .Top = 5
  132.     .Caption = "Character"
  133.     .Hint = "Click to insert the selected Character"
  134.     .OnClick = "CharClick"
  135.   end with
  136.   list = Create("TListBox", form)
  137.   with list
  138.     .Parent = form
  139.     .Font.Name = "Courier New"
  140.     .Font.Size = 12
  141.     .TabWidth = 35
  142.     .Align = "alClient"
  143.     .OnDblClick = "LstDlbClick"
  144.     .Hint = "Double Click to insert the selected HTML Entity"
  145.     .Items.LoadFromFile(lstfile)
  146.     ' Character vbTab Char_Code vbTab HTML_Code
  147.     for i = 0 to .Items.Count - 1
  148.       p = InStr(1, .Items(i), vbTab)
  149.       v = CInt(Mid(.Items(i), 1, p))
  150.       .Items(i) = Chr(v) & vbTab & .Items(i)
  151.     next
  152.   end with
  153.   form.ShowModal
  154.   form.Free
  155. end sub
  156.